class Snapshot < ActiveRecord::Base
  belongs_to :meta
  def snapshot=(snapshot_field)
    self.name = base_part_of(snapshot_field.original_filename)
    self.content_type = snapshot_field.content_type.chomp
    self.data = snapshot_field.read
  end
  
  def base_part_of(file_name)
    name = File.basename(file_name)
    name.gsub(/[^\w._-]/, '')
  end
end
